package com.lp.mgt.configs;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class StaticResourceConfig extends WebMvcConfigurationSupport{
	@Value("${localFilePath}")
	private String filePath;
	@Value("${showFilePath}")
	private String showPath;
	
	@Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        //一定要加上这里的代码，如果不加意味着static不是静态资源，MVC会把他当成一个请求，然后会拦截
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler(showPath+"**").addResourceLocations("file:"+filePath);
        super.addResourceHandlers(registry);
    }

}
